// pages/mine/mine.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabbarIndex: 4,
    tabbar: [
      {
        img: 'https://crm.bxwhl.com/static/tabbar/index.png',
        imgSelect: 'https://crm.bxwhl.com/static/tabbar/index-select.png',
        text: '名片',
        url: '/pages/index/index',
      },
      {
        img: 'https://crm.bxwhl.com/static/tabbar/goods.png',
        imgSelect: 'https://crm.bxwhl.com/static/tabbar/goods-select.png',
        text: '产品',
        url: '/pages/product/product',
      },
      {
        img: 'https://crm.bxwhl.com/static/tabbar/dynamic.png',
        imgSelect: 'https://crm.bxwhl.com/static/tabbar/dynamic-select.png',
        text: '动态',
        url: '/pages/dynamic/dynamic',
      },
      {
        img: 'https://crm.bxwhl.com/static/tabbar/website.png',
        imgSelect: 'https://crm.bxwhl.com/static/tabbar/website-select.png',
        text: '官网',
        url: '/pages/website/website',
      },
       {
        img: 'https://crm.bxwhl.com/static/tabbar/mine.png',
        imgSelect: 'https://crm.bxwhl.com/static/tabbar/mine-select.png',
        text: '我',
        url: '/pages/mine/mine',
      },
    ],
  },

  /**
   * 跳转
   */
  toPath: function (e) {
    if(!wx.getStorageSync('userInfo')){
      wx.navigateTo({
        url: '/pages/welcome/welcome',
      })
      return;
    }
    var path = e.currentTarget.dataset.path;
    wx.navigateTo({
      url: path,
    })
  },
  toBeGo:function(){
    wx.showToast({
      title: '暂无奖品信息',
      icon: 'none',
    })
  },
  tabbarNav: function (e) {
    var url = e.currentTarget.dataset.url;
    wx.redirectTo({
      url: url,
    })
  },

  // 我的会员卡
  toMyCard () {
    wx.navigateTo({
      url: '/pages/vipcoupon/vipcoupon',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let _this = this
    let userInfo = wx.getStorageSync('userInfo');
    if(!userInfo){
      wx.navigateTo({
        url: '/pages/welcome/welcome',
      })
      return;
    }
    _this.setData({
      userInfo: userInfo,
      pageShow: true
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
})